﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Transactions {
    import Engine.Managers.*;
    import Events.*;
    import flash.utils.*;
    import Classes.*;
    import Display.*;

    public class TMission extends TFarmTransaction {

        protected var m_mission:Mission;
        protected var m_userId:String;
        protected var m_missionPopup:MissionPopup;

        public function TMission(){
            this.m_userId = Global.player.snUser.uid;
        }
        override protected function onComplete(_arg1:Object):void{
            var _local2:Player;
            super.onComplete(_arg1);
            if (_arg1){
                if (_arg1.hostUserId){
                    _local2 = Global.player.findFriendById(_arg1.hostUserId);
                };
                this.m_mission = new Mission(_arg1.type, this.m_userId, _arg1.hostUserId, _arg1.hitLimit, _local2);
            };
        }
        protected function displayMission(_arg1:String="friendVisit"):void{
            if ((((this.m_missionPopup == null)) && (this.m_mission.hostPlayer))){
                this.m_missionPopup = new MissionPopup(this.m_mission, _arg1);
                this.m_missionPopup.addEventListener(CloseEvent.CLOSE, this.onClose);
            };
        }
        protected function validateMissionTime(_arg1:int):Boolean{
            var _local2:int = int((GlobalEngine.getTimer() * 0.001));
            var _local3:Boolean;
            if ((_local2 - _arg1) > Global.gameSettings.getInt("missionPerUserTimeLimit")){
                _local3 = true;
            };
            return (_local3);
        }
        protected function sendNoMissionStats(_arg1:String):void{
            if (this.m_mission){
                StatsManager.count(((MissionPopup.COUNTER + "_") + _arg1), "no_mission");
            };
        }
        protected function onClose(_arg1:CloseEvent):void{
            this.m_missionPopup.removeEventListener(CloseEvent.CLOSE, this.onClose);
            this.m_missionPopup = null;
        }
        override protected function onFault(_arg1:int, _arg2:String):void{
            GlobalEngine.log("Missions", ((("Fault in " + getQualifiedClassName(this)) + ": ") + _arg2));
        }

    }
}//package Transactions 
